Trim trailing dot from trusted IMDS hostnames - #652
Open
bitterpanda63 wants to merge 3 commits into
Open
Conversation
DNS resolvers may return hostnames with a trailing dot (e.g. `metadata.google.internal.`), which is a valid FQDN form. The previous direct equality check failed to match these, so they would not be skipped and could cause false-positive stored-SSRF blocks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expand normalize_hostname (sinks/socket) to also lowercase and strip
trailing dots so it is a proper canonical form for all hostname
comparisons. Use it in is_trusted_hostname instead of inline .lower()
.rstrip(".").
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Importing from sinks.socket in vulnerabilities.ssrf.imds created a cycle through sinks.socket.__init__ → aikido_zen.vulnerabilities. Move the implementation to helpers/normalize_hostname.py and have sinks/socket/normalize_hostname.py re-export from there. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bitterpanda63
force-pushed
the
fix/trusted-hostname-trailing-dot
branch
from
July 28, 2026 16:50
fc46c9a to
6e725f5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DNS resolvers sometimes return fully-qualified domain names with a trailing dot (e.g.
metadata.google.internal.). The previous direct equality check inis_trusted_hostnamedid not match this form, so GCP IMDS requests could be incorrectly flagged as stored SSRF..lower().rstrip('.')before the trusted-host lookupThis is the same fix already applied in firewall-go (PR #459 /
hostname-trailing-dot). Ported to Python, Ruby, .NET, PHP, and Java.Test plan
poetry run pytest aikido_zen/vulnerabilities/ssrf/imds_test.pypassesSummary by Aikido
🚀 New Features
⚡ Enhancements
🐛 Bugfixes
🔧 Refactors
More info